import { BusinessException } from '@/common';
import {
  PipeTransform,
  Injectable,
  ArgumentMetadata
} from '@nestjs/common';

@Injectable()
export class AttachementSize implements PipeTransform {
  transform(value: Express.Multer.File, metadata: ArgumentMetadata) {
    if (value.size > 5 * 1024) {
      throw new BusinessException({
        code: 400,
        message: '文件大小不能超过5KB'
      });
    }
    return value;
  }
}
